package com.as.server;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;

import com.as.client.services.SimpleService;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;


public class SimpleServiceImpl extends RemoteServiceServlet implements SimpleService{
	
	private static final long serialVersionUID = 1L;


	
	public String getHelloString(){
		String s = GWTServiceComponent.getInstance().getHello();
		return s; 
	}
	
	public ArrayList<ArrayList<Double>> getJitterList(){
		ArrayList<ArrayList<Double>> jList =null; 
		System.out.println("inicializacion de la lista");
			jList= GWTServiceComponent.getInstance().getJitter();
			System.out.println("llamada hecha");
		
		if(jList==null){
			
			System.out.println("lista vacia de jitter");
			return null; 
		}
		else{
			 //print 
			int count = 0;
			Iterator<ArrayList<Double>> i = jList.iterator();
				while(i.hasNext()){
					ArrayList<Double> aux = i.next();
					
					for (Double element: aux) {

						System.out.println("JITTER SIMPLE"+element.doubleValue());
						}
					
					count++;
				}
			
			
		
			
			return jList;
		}
	}
	
	public ArrayList<ArrayList<Double>> getBwList(){
		ArrayList<ArrayList<Double>> bwList =null; 
		System.out.println("inicializacion de la lista");
			bwList= GWTServiceComponent.getInstance().getBW();
			System.out.println("llamada hecha");
		
		if(bwList==null){
			
			System.out.println("lista vacia de bw");
			return null; 
		}
		else{
			 //print 
			int count = 0;
			Iterator<ArrayList<Double>> i = bwList.iterator();
				while(i.hasNext()){
					ArrayList<Double> aux = i.next();
					
					for (Double element: aux) {

						System.out.println("BW SIMPLE"+element.doubleValue());
						}
					
					count++;
				}
			
			
		
			
			return bwList;
		}
	}
	

	public ArrayList<ArrayList<Timestamp>> getTimeList(){
		ArrayList<ArrayList<Timestamp>> tList =null;  
		System.out.println("inicializacion de la lista");
			tList=GWTServiceComponent.getInstance().getTime();
			System.out.println("llamada hecha");
		if(tList==null){
			System.out.println("lista vacia de jitter");
			return null; 
		}
		else{
			Iterator<ArrayList<Timestamp>> i = tList.iterator();
			 //print 
			int count = 0;
			while(i.hasNext()){
				ArrayList<Timestamp> aux = i.next();
				for (Timestamp element: aux) {

					System.out.println("TIME SIMPLE:"+element.toString());
					}
				count++;
				
			}
			
			return tList;
		}
	}
	
	
	public ArrayList<ArrayList<Double>> getLostList(){
		ArrayList<ArrayList<Double>> lostList =null; 
		System.out.println("inicializacion de la lista");
			lostList= GWTServiceComponent.getInstance().getLost();
			System.out.println("llamada hecha");
		
		if(lostList==null){
			
			System.out.println("lista vacia de lost");
			return null; 
		}
		else{
			 //print 
			int count = 0;
			Iterator<ArrayList<Double>> i = lostList.iterator();
				while(i.hasNext()){
					ArrayList<Double> aux = i.next();
					
					for (Double element: aux) {

						System.out.println("LOST SIMPLE"+element.doubleValue());
						}
					
					count++;
				}
			
			
		
			
			return lostList;
		}
	}
	
	
	public ArrayList<String> getInterfaceList(){
		ArrayList<String> interList = null; 
		interList=GWTServiceComponent.getInstance().getInterface();
	if(interList==null){
			
			System.out.println("lista vacia de interfaces");
			return null; 
		}
	else{
		
		return interList;
	}
	}
	}
	


